﻿@model ProductItem
<div class="modal-dialog">
    <div class="modal-content">
        @using (Html.BeginForm())
        {
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;</button>
                <h4 class="modal-title">
                    修改名称</h4>
            </div>
            <div class="modal-body">
                <dl class="dl-horizontal">
                    <dt style="width: 80px;">名 称：</dt>
                    <dd style="margin-left: 80px;">
                        <p>
                            @Html.TextArea("name", Model.Name, 2, 40, new { @class = "form-control", onkeyup = "checkValue(this);" })
                        </p>
                    </dd>
                    <dt style="width: 80px;">副名称：</dt>
                    <dd style="margin-left: 80px;">
                        <p>
                            @Html.TextArea("subname", Model.SubName, 2, 40, new { @class = "form-control", onkeyup = "checkValue(this);" })</p>
                    </dd>
                </dl>
            </div>
            <div class="modal-footer">
                <p id="message" class="pull-left color-red">
                </p>
                <button type="button" class="btn btn-primary" onclick="submitForm(this.form,@(Model.Id))">
                    确 认</button>
            </div>
        }
    </div>
</div>
<script type="text/javascript">
    function checkValue(obj) {
        var val = $(obj).val();

    }
    function submitForm(form, target) {
        var param = $(form).serialize();
        $.postJSON(form.action, param, function (result) {
            if (result.Status) {
                $("#item-name-" + target).html(result.Data);
                $("#item-name-sub-" + target).html(result.Extra);
                $('#message', form).css('color', 'green').html("更新商品名称成功！");
            }
            else {
                $('#message', form).css('color', 'red').html(result.Message);
            }
        });
    }
</script>
